/**
 * @Title:IComboUtils.java
 * @Description:TODO
 * @author shan
 * @date 2015-4-7 下午10:36:58
 */
package com.shan.ai.combo;

import java.util.ArrayList;

/**
 * @author ShanSheng
 * 
 */
public interface IComboConstant {

    public static final int MAX_ROW = 5;
    public static final int MAX_COLUMN = 6;

    public static final int MAX_STEP = 20;
    public static final int MAX_COST = 25;
    public static final int OVER_TIME = 30 * 1000;

    public enum BeadType {
        fire, water, wood, light, dark, heart, none, unknown
    }

    public enum Direct {
        up, down, left, right
    }

    class Point {
        public int x;
        public int y;
        public BeadType type;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
            this.type = BeadType.unknown;
        }
        
        public Point(int x, int y, BeadType type) {
            this.x = x;
            this.y = y;
            this.type = type;
        }

        @Override
        public boolean equals(Object o) {

            if (o instanceof Point) {
                Point point = (Point) o;
                if (this.x == point.x && this.y == point.y) {
                    return true;
                }
            }

            return false;
        }

        @Override
        public String toString() {
            return "(" + this.x + "," + this.y + ")";
        }
        
        @Override
        public int hashCode(){
            return (x+y) % 10;
        }
    }

    class BeadList extends ArrayList<IComboConstant.Point> {

        public BeadType type = BeadType.unknown;

        @Override
        public boolean add(IComboConstant.Point o) {
            if (!contains(o)) {
                return super.add(o);
            }
            return true;
        }

        public boolean addAllOnce(BeadList list) {
            for (Point point : list) {
                add(point);
            }
            return true;
        }
    }
}
